//
//  PlatformEquityViewController.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/8.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "TT_BaseNaviView.h"
#import "BA_PNGHeaderView.h"

#import "PlatformEquityViewController.h"

@interface PlatformEquityViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableview;

@property (nonatomic, strong) BA_PNGHeaderView *headerView;

@property (nonatomic, strong) TT_BaseNaviView *naviView;


@end

@implementation PlatformEquityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
}

- (void)initView {
    

    //屏幕常亮
    [UIApplication sharedApplication].idleTimerDisabled = YES;
    self.navigationController.navigationBarHidden = YES;
    #if RT_INTERACTIVE_PUSH
        self.rt_navigationController.rt_enableInteractivePush = YES;
    #endif
    
    if([self.tableview respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
        if (@available(iOS 11.0, *)) {
            self.tableview.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;
        } else {
            // Fallback on earlier versions
        }
    }
    
    [self.view addSubview:self.tableview];
    
    self.naviView = [[NSBundle mainBundle] loadNibNamed:@"TT_BaseNaviView"owner:nil options:nil].firstObject;
    self.naviView.titleLab.text = @"";
    [self.view addSubview:self.naviView];
    
    
    [self.naviView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(kStatusBarHeight + NavBar_Height);
    }];
    
    [self.tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
        
    self.headerView =  [[NSBundle mainBundle] loadNibNamed:@"BA_PNGHeaderView"owner:nil options:nil].firstObject;
    self.headerView.frame = CGRectMake(0, 0, TTScreenWidth, TTScreenWidth * 4.229);

//    [self.headerView.mainImageView
//     sd_setImageWithURL:[NSURL URLWithString:B_PLATFORM_SERVICE_DETAIL]
//     placeholderImage:nil
//     options:SDWebImageProgressiveLoad];
    
    [SVProgressHUD showWithStatus:@"正在加载"];
    [self.headerView.mainImageView sd_setImageWithURL:[NSURL URLWithString:B_PLATFORM_SERVICE_DETAIL]  placeholderImage:[UIImage imageNamed:@"pingtaiquanyidetail"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        [SVProgressHUD dismiss];
    }];
    
    
    
    self.tableview.tableHeaderView = self.headerView;
    self.headerView.autoresizingMask = UIViewAutoresizingNone;
    
    
    [self.tableview reloadData];
    
    [self initViewAction];
}



- (void)goBack {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initViewAction {
    
    [self.naviView.backBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark UITableviewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 0;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return CGFLOAT_MIN;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [UITableViewCell new];
}

- (UITableView *)tableview {
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableview.backgroundColor =  UIColorHex(0xf1f1f1);

        _tableview.showsHorizontalScrollIndicator = NO;
        _tableview.showsVerticalScrollIndicator = NO;
        
        _tableview.estimatedSectionHeaderHeight = 0;
        _tableview.estimatedSectionFooterHeight = 0;
        _tableview.estimatedRowHeight = 0;
    }
    return _tableview;
}

@end
